<script language="javascript" src="/Public/static/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<style>
select{height:30px;}
</style>
<div id="main-content">
    <div id="main" class="main">
		<div class="user-hd">
			<h2>代理商管理>>{$page_title}</h2>
			<a  href="{:U('Agent/add')}" class="kehu uploadify-button" style="position: absolute;  bottom: 8px; right: 25px;">新增</a>
		</div>	
		<div class="clearfix searchspin">
			<dl>
				<dt>筛选条件:</dt>
				<dd>
					<form method="get" action="{:U('Admin/Agent/agentList')}">
						加盟时间：<input type="text" name="create_time_start" id="create_time_start" value="{$_GET['create_time_start']}" class="Wdate bg-input mr5" <literal>onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'create_time_end\')||\'%y-%M-%d\'}'})"</literal> readonly="readonly" size="30" style="width: 90px;"/>
                        <input type="text" name="create_time_end" id="create_time_end" value="{$_GET['create_time_end']}" class="Wdate bg-input mr5" <literal>onfocus="WdatePicker({minDate:'#F{$dp.$D(\'create_time_start\')}',maxDate:'%y-%M-%d'})"</literal> readonly="readonly" size="30" style="width: 90px;" />
						代理商状态：<select name="agent_status" class="" style="height:30px;">
									  <option value ="0" <?php if($_GET['agent_status'] ==0){echo 'selected';} ?> >全部</option>
									  <option value ="1" <?php if($_GET['agent_status'] ==1){echo 'selected';} ?> >正常</option>
									  <option value ="2" <?php if($_GET['agent_status'] ==2){echo 'selected';} ?> >停用</option>
									</select>
						地区：{:w('Area/multLevel', array(1, '', 1, $_GET['mutil_level_data_1_id_1'], $_GET['mutil_level_data_1_id_2'], $_GET['mutil_level_data_1_id_3']))}			
						<input type="text" name="agent_name" class="bg-input w195" value="{$_GET['agent_name']}" placeholder="请输入代理商名称" value="">
						<a href="{:U('Admin/Agent/agentList')}" class="sblue-btn" style="height:28px;width:68px;">清空 </a>
						<button class="sblue-btn" id="video_search" onclick="this.form.submit();">检索</button>
					</form>
				</dd>
			</dl>
		</div>
        <div class="spin-cont">
			<p style="padding-bottom:20px;">
				代理商数量：<span class="text_red">{$count}</span> 家；
				代理商影院数量：<span class="text_red">{$cinemaCount|default = '0'}</span> 名
			</p>		
            <table>
                <tr>
                    <th class="spin-tit" style="width: 160px;">代理商编号</th>
                    <th class="spin-tit" style="width: 160px;">代理商名称</th>
                    <th style="width: 130px;">加盟时间</th>
                    <th style="width:  80px;">代理商用户</th>
                    <th style="width: 180px;">代理有效期</th>
                    <th style="width: 100px;">代理商状态</th>
                    <th style="width: 320px;">操作</th>
                </tr>
                <volist name="list" id="vo">
                <tr>
                    <td class="spin-tit">{$vo.agentid}</td>
                    <td class="spin-tit">{$vo.agent_name}</td>
                    <td>{$vo.agent_time|date="Y-m-d",###}</td>
                    <td>{$vo.id|getAgentUserNum}</td>
                    <td>{$vo.agent_starttime|date="Y-m-d",###} ~ {$vo.agent_endtime|date="Y-m-d",###}</td>
                    <td>
						<switch name="vo.agent_status">
							<case value="1"><font color="green">正常</font></case>
							<case value="2"><font color="red">停用</font></case>
						</switch>
					</td>
                    <td>
					<switch name="vo.agent_status">
						<case value="1"><a href="javascript:void(0)"  onclick="agentStop({$vo.id});" >停用</a></case>
						<case value="2"><a href="javascript:void(0)"  onclick="agentStart({$vo.id});" >启用</a></case>
					</switch>	
						&nbsp; | &nbsp;
                        <a href="{:U('Admin/Agent/edit',array('id'=>$vo['id']))}" >编辑</a>
                        &nbsp; | &nbsp;
                        <a href="{:U('Admin/Agent/detail',array('id'=>$vo['id']))}" >详情</a>
						&nbsp; | &nbsp;
						<a href="{:U('Admin/Agent/cinema',array('id'=>$vo['id']))}" >代理影院</a>
                    </td>
                </tr>
                </volist>
            </table>
            <div class="page txt-center">
                {$page}
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
	var id;
	function agentStop(id){
		$.ajax({
			url:"{:U('Admin/Agent/stop')}",
			type:"post",
			data:{'id':id},
			success:function(data,status,xhr){
					alertMessage(data.info, '', 2);
					setInterval(function(){
						window.location.reload();
					},2000);
					
			},
		})
	}
	function agentStart(id){
		$.ajax({
			url:"{:U('Admin/Agent/start')}",
			type:"post",
			data:{'id':id},
			success:function(data,status,xhr){
					alertMessage(data.info, '', 2);
					setInterval(function(){
						window.location.reload();
					},2000);
					
			},
		})
	}	
	
var area1 = "{$_GET['mutil_level_data_1_id_1']}";  //解决选择二级 三级地区，再选择一级为不选时候 产生的空白选项
var area2 = "{$_GET['mutil_level_data_1_id_2']}";
var area3 = "{$_GET['mutil_level_data_1_id_3']}";

if(area1 == '' && area2 != ''){
	$("#mutil_level_data_1_id_2").remove();
	$("#mutil_level_data_1_id_3").remove();
}

if(area2 == ''){
	$("#mutil_level_data_1_id_2").prepend('<option selected="selected" value=""></option>');
}
if(area3 == ''){
	$("#mutil_level_data_1_id_3").prepend('<option selected="selected" value=""></option>');
}
	
</script>